<template>
	<view>
		<view class="bkk" v-if="open_wallet == false">
			<view class="bc b10">
				<i class="ri-information-fill" style="color:#008040;font-size:24px;"></i>
				<!-- <i-icon size="24px" color="#008040" name="information-fill"></i-icon> -->
				温馨提示
			</view>
			<view class="f14 b10">你出售废旧的报酬，将通过电子钱包打款给你</view>
			<button @click="toOpenWallet">立即开通</button>
		</view>
		<view v-else class="bkk">
			<view class="bc b20">
				<i class="ri-hand-heart-fill" style="color:#008040;font-size:30px;"></i>
				<!-- <i-icon size="30px" color="#008040" name="hand-heart-fill"></i-icon> -->
				财务订单明细
			</view>
			<view class="">
				<view v-if="orderList && orderList.length>0" class="bl b10" v-for="(item,index) in orderList">
					<view class="">
						<view class="">{{item.payerName}}</view>
						<!-- <view class="">{{item.payeeBankAccName}} {{item.payeeBankCardNo}}</view> -->
						<view class="f12">{{item.createDatetime}}</view>
					</view>
					<view>
						<font v-if="item.type=='转账'" color="#06aa03">{{item.type}}</font>
						<font v-else-if="item.type=='提现'" color="#0088cc">{{item.type}}</font>
						<font v-else-if="item.type=='分账'" color="#ffac67">{{item.type}}</font>

						<font v-if="item.status=='成功'" color="#06aa03">{{item.status}}</font>
						<font v-else-if="item.status=='失败'" color="#ff0000">{{item.status}}</font>
						<font v-else-if="item.status=='处理中'" color="#ffdc14">{{item.status}}</font>
					</view>
					<view class="red">￥{{item.amount}}</view>
				</view>
				<view v-else style="color: #999999;text-align: center;font-size:30rpx;">数据为空</view>
				<view style="display: flex;justify-content: space-around;line-height: 60rpx;">
					<view @click="getOrderList(current-1,size,zbAccount)" class="p-btn">上一页</view>
					<view @click="getOrderList(current+1,size,zbAccount)" class="p-btn">下一页</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				zbAccount: '',
				orderList: [],
				pages: '',
				total: '',
				open_wallet: true,
				current: 1,
				size: 10
			}
		},
		methods: {
			/**
			 *  获取回收订单列表
			 * @param {Object} account
			 */
			getOrderList(current, size, account) {
				account = account ? account : '';
				current = current && current > 0 ? current : 1;
				size = size ? size : 10;
				if (current <= 0) return;
				let _this = this
				this.httpRequest({
					url: "/order/list?current=" + current + "&size=" + size + "&zbAccount=" + account,
					method: 'GET',
					header: {
						token: uni.getStorageSync('token')
					},
					fn: (data) => {
						// console.info(data)
						_this.orderList = data.records
						_this.pages = data.pages
						_this.total = data.total
						_this.current = parseInt(data.current)
						_this.size = parseInt(data.size)
					},
					fail: (e) => {
						console.warn(e)
					}
				})
			},
			/**
			 * 查询账户信息（看看是否有个人户数据）
			 */
			findAccInfo() {
				let _this = this;
				uni.request({
					url: this.baseURL + '/gr/find/one',
					method: 'POST',
					header: {
						token: uni.getStorageSync('token')
					},
					success: (res) => {
						// console.log('=====', res.data)
						let data = res.data
						if (data.success == true) {
							_this.open_wallet = true; //已开通钱包
							data = data.data[0]
							this.zbAccount = data.virtualAccNo || ''
							this.getOrderList(this.current, this.size, this.zbAccount)
						} else {
							_this.open_wallet = false; //已开通钱包
							uni.showToast({
								title: "您还未开通电子钱包",
								icon: 'error',
								duration: 3000
							})
						}
					},
					fail: (e) => {
						console.warn(e)
					}
				})
			},
			toOpenWallet: function() {
				uni.navigateTo({
					url: 'u-ktqb'
				})
			}
		},
		onLoad(p) {
			// console.log(p.openState)
			// if(p.openState == 1){
			// 	this.open_wallet = true;
			// }
			this.findAccInfo()
		}
	}
</script>

<style>
	.p-btn {
		font-size: 20rpx;
	}

	.p-btn:active {
		color: #007AFF;
	}
</style>
